<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>spips: xspips_slave_polled_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">spips
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xspips__slave__polled__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xspips_slave_polled_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains a design example using the SPI controller in slave mode. </p>
<p>This examples performs transfers in polled mode and has been tested with Aardvark Analyzer as Master. This example echoes data which it receives from the master. The slave controller expects MAX_DATA bytes of data from the master to transmit onto the SPI bus which the slave will receive into its Rx buffer. It will poll until the Rx FIFO is filled with the Threshold limit of data which is set to MAX_DATA. On sending data, the master will receive dummy bytes in response. Master has to send MAX_DATA dummy bytes to read back the echoed data.</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>The slave mode test needs an external master to send data to the Spi device. This example has been tested with Aardvark Analyzer as Master. The Clock Polarity and Phase should match between master and the slave.</p>
<pre>
 MODIFICATION HISTORY:</pre><pre> Ver   Who Date     Changes
</p>
<hr/>
<p>
 2.0   sb  08/22/14  First release
       ms   04/05/17 Modified Comment lines in functions to
                     recognize it as documentation block for doxygen
                     generation.
 3.9   sb   07/05/23 Added support for system device-tree flow.
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:abb3b67e673874014e8077718c84acc8a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__slave__polled__example_8c.html#abb3b67e673874014e8077718c84acc8a">SpiSlaveRead</a> (int ByteCount)</td></tr>
<tr class="memdesc:abb3b67e673874014e8077718c84acc8a"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function reads from the Rx buffer.  <a href="#abb3b67e673874014e8077718c84acc8a">More...</a><br/></td></tr>
<tr class="separator:abb3b67e673874014e8077718c84acc8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a877b44a69fdc0b32b04ae2754f188bca"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__slave__polled__example_8c.html#a877b44a69fdc0b32b04ae2754f188bca">SpiSlaveWrite</a> (u8 *Sendbuffer, int ByteCount)</td></tr>
<tr class="memdesc:a877b44a69fdc0b32b04ae2754f188bca"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function writes Data into the Tx buffer.  <a href="#a877b44a69fdc0b32b04ae2754f188bca">More...</a><br/></td></tr>
<tr class="separator:a877b44a69fdc0b32b04ae2754f188bca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeaa0d12afde29602122269d05baf4171"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__slave__polled__example_8c.html#aeaa0d12afde29602122269d05baf4171">SpiPsSlavePolledExample</a> (u16 SpiDeviceId)</td></tr>
<tr class="memdesc:aeaa0d12afde29602122269d05baf4171"><td class="mdescLeft">&#160;</td><td class="mdescRight">The purpose of this function is to illustrate how to use the <a class="el" href="struct_x_spi_ps.html" title="The XSpiPs driver instance data. ">XSpiPs</a> device driver in Slave mode.  <a href="#aeaa0d12afde29602122269d05baf4171">More...</a><br/></td></tr>
<tr class="separator:aeaa0d12afde29602122269d05baf4171"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspips__slave__polled__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function to call the SPI Slave Example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Main function to call the SPI Slave Example. </p>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if successful</li>
<li>XST_FAILURE if not successful</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None </dd></dl>

<p>References <a class="el" href="xspips__slave__polled__example_8c.html#aeaa0d12afde29602122269d05baf4171">SpiPsSlavePolledExample()</a>.</p>

</div>
</div>
<a class="anchor" id="aeaa0d12afde29602122269d05baf4171"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int SpiPsSlavePolledExample </td>
          <td>(</td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>SpiDeviceId</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The purpose of this function is to illustrate how to use the <a class="el" href="struct_x_spi_ps.html" title="The XSpiPs driver instance data. ">XSpiPs</a> device driver in Slave mode. </p>
<p>This function reads data from a SPI Master and will echo it back to the Master.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">SpiDeviceId</td><td>is the Instance Id of SPI in the system.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if successful</li>
<li>XST_FAILURE if not successful</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None </dd></dl>

<p>References <a class="el" href="struct_x_spi_ps___config.html#a9b11063c0ae635e0284463e9edf0fdf8">XSpiPs_Config::BaseAddress</a>, <a class="el" href="xspips__slave__polled__example_8c.html#abb3b67e673874014e8077718c84acc8a">SpiSlaveRead()</a>, <a class="el" href="xspips__slave__polled__example_8c.html#a877b44a69fdc0b32b04ae2754f188bca">SpiSlaveWrite()</a>, <a class="el" href="group__spips.html#gabfabf86279474d10c04bfe97f3386a64">XSpiPs_CfgInitialize()</a>, <a class="el" href="group__spips.html#ga4a6535d62a7cad8209d615146f5f050c">XSPIPS_CR_CPHA_MASK</a>, <a class="el" href="group__spips.html#gad085464580e29731d0eafc1b6eb4bdb0">XSPIPS_CR_CPOL_MASK</a>, <a class="el" href="group__spips.html#gae33752db88677fe0580abb65d6ba70cf">XSpiPs_Disable</a>, <a class="el" href="group__spips.html#ga7b3a41972453b0dfb7ec90f3972ddc74">XSpiPs_Enable</a>, <a class="el" href="group__spips.html#ga70c86f3842f5996d9d7fc874466f4136">XSpiPs_LookupConfig()</a>, <a class="el" href="group__spips.html#ga4f14bfc3ddd296adb08843dbbe30a306">XSpiPs_SetOptions()</a>, and <a class="el" href="group__spips.html#gabf7789f973a99a1192e89e6df23b8d84">XSpiPs_SetRXWatermark</a>.</p>

<p>Referenced by <a class="el" href="xspips__slave__polled__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<a class="anchor" id="abb3b67e673874014e8077718c84acc8a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SpiSlaveRead </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ByteCount</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function reads from the Rx buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ByteCount</td><td>is the number of bytes to be read from Rx buffer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="struct_x_spi_ps___config.html#a9b11063c0ae635e0284463e9edf0fdf8">XSpiPs_Config::BaseAddress</a>, <a class="el" href="struct_x_spi_ps.html#a2f23279c800d3c5e2d91622b1fa64aeb">XSpiPs::Config</a>, <a class="el" href="group__spips.html#ga72359f1b9dc7e5c5f0c5fdb3f6d62fc4">XSPIPS_IXR_RXNEMPTY_MASK</a>, <a class="el" href="group__spips.html#ga3c4c628392bc69b6295b28d8736d3c14">XSpiPs_ReadReg</a>, and <a class="el" href="group__spips.html#ga29c45b21694c49560b05b5773a976ff5">XSPIPS_SR_OFFSET</a>.</p>

<p>Referenced by <a class="el" href="xspips__slave__polled__example_8c.html#aeaa0d12afde29602122269d05baf4171">SpiPsSlavePolledExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a877b44a69fdc0b32b04ae2754f188bca"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SpiSlaveWrite </td>
          <td>(</td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>Sendbuffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ByteCount</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function writes Data into the Tx buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Sendbuffer</td><td>is the buffer whose data is to be sent onto the Tx FIFO. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>is the number of bytes to be read from Rx buffer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="struct_x_spi_ps___config.html#a9b11063c0ae635e0284463e9edf0fdf8">XSpiPs_Config::BaseAddress</a>, <a class="el" href="struct_x_spi_ps.html#a2f23279c800d3c5e2d91622b1fa64aeb">XSpiPs::Config</a>, <a class="el" href="group__spips.html#gad82a11ae1f014d578834f1522a8a94ca">XSPIPS_FIFO_DEPTH</a>, <a class="el" href="group__spips.html#gad8525498172f10882b4a7cf59c660577">XSPIPS_IXR_TXOW_MASK</a>, <a class="el" href="group__spips.html#ga3c4c628392bc69b6295b28d8736d3c14">XSpiPs_ReadReg</a>, and <a class="el" href="group__spips.html#ga29c45b21694c49560b05b5773a976ff5">XSPIPS_SR_OFFSET</a>.</p>

<p>Referenced by <a class="el" href="xspips__slave__polled__example_8c.html#aeaa0d12afde29602122269d05baf4171">SpiPsSlavePolledExample()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
